Blueprint Help Send comments on this topic.
Accessing Parent Objects

Glossary Item Box

Active objects sometimes need to access objects that are owned by their parent circuit.

Two common examples are

    1. Circuit Workspace : Circuit workspace allows all active objects to access a common workspace structure that contains common constants or data.
    2. Devices : Devices are created and owned by a circuit, but may need to be accessed by several threads (Eg TCP/IP devices require two threads one to read and one to write.)

To enable these accesses all objects have a Parent() function that returns a reference to the parent circuit instance. This instance can then be used to access any available objects.

 

Uns MyThrdElem::Execute()
{
   MyCctElem& parent = this->Parent();

   ScratchPad& pad = parent.Workspace().Data().ScratchPad();

   parent.mTcpDev.Write( pad, pad.Size() );

   pad.Increment();
}

 

Of course Grand-parent circuits etc. can be accessed by recursive calls to the parent's parent etc.

 

Uns MyThrdElem::Execute()
{
   MyGPCctElem& grandparent = this->Parent().Parent();

   ScratchPad& pad = grandparent.Workspace().Data().ScratchPad();

   grandparent.mTcpDev.Write( pad, pad.Size() );

   pad.Increment();
}